<?php

namespace app\common\validate\Schoolwall;

use think\Validate;

class User extends Validate
{
    // 验证规则
    protected $rule =   [
        'email'    => 'require|email|unique:user',
        'username' => 'require|unique:user',
        'password' => 'require',
        'salt'     => 'require',
        'qq'       => 'require',
        'mobile'   => 'require|number|unique:user',
    ];

    // 错误提示信息
    protected $message  =   [
        'email.require'    => '邮箱必须填写',
        'email.email'      => '邮箱格式不正确',
        'email.unique'     => '该邮箱已被注册',
        'username.require' => '用户名必须填写',
        'username.unique'  => '用户名已存在',
        'password.require' => '密码必须填写',
        'salt.require'     => '安全盐值不能为空',
        'qq.require'       => 'QQ号不能为空',
        'mobile.require'   => '手机号不能为空',
        'mobile.number'    => '手机号格式不正确',
        'mobile.unique'    => '手机号已存在',
    ];

    // 验证场景
    protected $scene = [
        'register' => ['email', 'username', 'password', 'salt'],
        'idedit'   => ['mobile', 'qq'],
    ];
}
